<template>
  <div id="FormSearch">
    <el-form :model="form" ref="form" label-width="60px">
      <p>查询条件</p>
      <el-form-item label="年龄段" prop="startAge">
        <el-input-number
          v-model="form.startAge"
          controls-position="right"
          :min="18"
          :max="100"
        ></el-input-number>
        <span> 至 </span>
        <el-input-number
          v-model="form.endAge"
          controls-position="right"
          :min="18"
          :max="100"
        ></el-input-number>
      </el-form-item>
      <el-form-item label="工龄段 ">
        <el-input-number
          v-model="form.startWork"
          controls-position="right"
          :min="0"
          :max="100"
        ></el-input-number>
        <span> 至 </span>
        <el-input-number
          v-model="form.endWork"
          controls-position="right"
          :min="1"
          :max="100"
        ></el-input-number>
      </el-form-item>
      <el-form-item label="按钮">
        <el-button type="primary" icon="el-icon-thumb" @click="submit"
          >搜索</el-button
        >
        <el-button type="primary" icon="el-icon-delete" @click="reset"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getSearchData } from 'network/search'
export default {
  name: 'FormSearch',
  data() {
    return {
      form: {
        startWork: 1,
        endWork: 1,
        startAge: 18,
        endAge: 18
      }
    }
  },

  methods: {
    submit() {
      if (this.form.startAge <= this.form.endAge) {
        this.$message({
          message: '提交成功',
          type: 'success'
        })
        this.$router.push({
          name: 'result',
          params: {
            form: this.form
          }
        })
      } else {
        this.$message.error('年龄段输入不合法')
      }

      // console.log(getSearchData)
    },

    reset() {
      this.$refs.form.resetFields()
    }
  }
}
</script>

<style  scoped>
#FormSearch {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-top: 20px;
  /* align-items: center; */
}
#FormSearch >>> form {
  margin: 20px 15px 0 10px;
  padding: 5px;
  width: 36%;
  text-align: center;
  border: 2px solid #eee;
}

p {
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid #eee;
}
</style>